package com.cennavi.buss.service.imp;

import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import com.cennavi.buss.FeignMultipartSupportConfig;
import com.cennavi.buss.service.UploadService;
import com.cennavi.minemap.bean.MessageBean;

@FeignClient(value = "upload-service", fallback = UploadService.class, configuration = FeignMultipartSupportConfig.class)
public interface IUploadService {
	@RequestMapping(method = RequestMethod.POST, value = "/service/upload/file", produces = {MediaType.APPLICATION_JSON_UTF8_VALUE},consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
	public MessageBean upload(@RequestParam(value = "name") String name, @RequestParam(value = "type") int type,
			@RequestParam(value = "userId") int userId, @RequestParam(value = "describe") String describe,
			@RequestPart(value = "file") MultipartFile file);

	@RequestMapping(method = RequestMethod.GET, value = "/service/upload/{id}")
	public MessageBean queryById(@PathVariable(value = "id") int id);

	@RequestMapping(method = RequestMethod.GET, value = "/service/upload/list/{userId}")
	public MessageBean queryByUserId(@PathVariable(value = "userId") int userId);

	@RequestMapping(method = RequestMethod.GET, value = "/service/upload/create/{id}/{uploadId}")
	public MessageBean createTable(@PathVariable(value = "id") int id, @PathVariable(value = "uploadId") int uploadId);

	@RequestMapping(method = RequestMethod.GET, value = "/service/upload/test/{id}")
	public MessageBean test(@PathVariable(value = "id") int id);

	@RequestMapping(method = RequestMethod.POST, consumes = "application/x-www-form-urldecoded", value = "/service/upload/detail/update/{userId}/{uploadId}")
	public MessageBean update(@PathVariable(value = "userId") int userId,
			@PathVariable(value = "uploadId") int uploadId, @RequestBody String json);

	@RequestMapping(method = RequestMethod.GET, value = "/service/upload/detail/list/{userId}/{uploadId}")
	public MessageBean queryUploadDetailList(@PathVariable(value = "userId") Integer userId,
			@PathVariable(value = "uploadId") Integer uploadId);

	@RequestMapping(method = RequestMethod.GET, value = "/service/upload/detail/byid/{userId}/{uploadId}/{id}")
	public MessageBean queryUploadDetailById(@PathVariable(value = "userId") Integer userId,
			@PathVariable(value = "uploadId") Integer uploadId, @PathVariable(value = "id") Integer id);

	@RequestMapping(method = RequestMethod.GET, value = "/service/upload/getSolu/{uploadId}")
	public MessageBean querySoluId(@PathVariable(value = "uploadId") Integer uploadId);

	@RequestMapping(method = RequestMethod.POST, consumes = "application/x-www-form-urldecoded", value = "/service/upload/setSolu")
	public MessageBean saveSoluId(@RequestBody String text);
}
